package com.example.rwq_test.anno.customAnno.scheduleLock;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Slf4j
@Component
public class BusinessSchedule {
    public static final String TASK_SCHEDULE = "RWQ_TEST_TASK_SCHEDULE";

    /**
     * 任务调度
     */
    @Scheduled(cron = "*/5 * * * * ?")
    @ScheduleLock(key = TASK_SCHEDULE, waitTime = 1000, leaseTime = 5000)
    public void doHandleTaskSchedule() {
        try {
            TimeUnit.MILLISECONDS.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
